package com.uhylab.uhuvinetest.utils.toastutil;

import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.uhylab.uhuvinetest.R;

/**
 * @author SamSarah
 * @version $Rev$
 * @time 2015/12/7 17:03
 * @des ${toast工具类}
 * @updateAuthor $Author$
 * @updateDate $Date
 * @updateDes ${TODO}
 */
public class ToastUtil {
    public static void show(Context context,String content){
        View view = LayoutInflater.from(context).inflate(R.layout.toast_util,null);
        TextView textView = (TextView) view.findViewById(R.id.toast_text);
        textView.setText(content);
        Toast toast = new Toast(context);
        //toast显示时长
        toast.setDuration(Toast.LENGTH_SHORT);
        //toast显示位置
//        toast.setGravity(Gravity.CENTER_HORIZONTAL,Gravity.CENTER_HORIZONTAL,Gravity.CENTER_HORIZONTAL);
        toast.setView(view);
        toast.show();
    }
    public static void show(Context context,int contentId){
        View view = LayoutInflater.from(context).inflate(R.layout.toast_util,null);
        TextView textView = (TextView) view.findViewById(R.id.toast_text);
        textView.setText(contentId);
        Toast toast = new Toast(context);
        //toast显示时长
        toast.setDuration(Toast.LENGTH_SHORT);
        //toast显示位置
        toast.setGravity(Gravity.CENTER_HORIZONTAL,Gravity.CENTER_HORIZONTAL,Gravity.CENTER_HORIZONTAL);
        toast.setView(view);
        toast.show();
    }
}
